package adapter;

import java.util.ArrayList;

import com.example.traffic_learning.R;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class GridAdapterHistoryQuestion extends BaseAdapter{
	private final Context context;
	private final ArrayList<HistoryQuestion> listItem;
	
	public GridAdapterHistoryQuestion(Context context, ArrayList<HistoryQuestion> listItem) {
		this.context = context;
		this.listItem = listItem;
	}
	

	@SuppressLint("ViewHolder")
	@Override
	public View getView(int index, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.grid_history_gridview_item, parent, false);
		TextView textView = (TextView)rowView.findViewById(R.id.textView_question_history);
		textView.setText(listItem.get(index).getQuestionNo());
		LinearLayout layout = (LinearLayout)rowView.findViewById(R.id.layout_item_history);
		if(listItem.get(index).getIsChecked()){
			layout.setBackgroundColor(Color.BLUE);
		}else{
			layout.setBackgroundColor(Color.GREEN);
		}
		return rowView;
	}
	
	@Override
	public int getCount() {
		return listItem.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}
}
